//
//
// Basic Object inline functions
//
//
inline
void BasicObject::SetMapChunk( MapChunk* mchk )
{
	mapChunk = mchk;
}

inline
MapChunk* BasicObject::GetMapChunk() const
{

	return mapChunk;
}

inline
const SHAPEID& BasicObject::ShapeID() const
{
	return shapeID;
}

inline
const char* BasicObject::Name() const
{
	return name;
}

inline
void BasicObject::GetLocalCoords( U7VECTOR3* vec3 ) const
{
	vec3->x = xt;
	vec3->y = yt;
	vec3->z = zlevel;
}

inline
void BasicObject::SetLocalCoords( unsigned char x, unsigned char y, unsigned char z )
{
	xt = x;
	yt = y;
	zlevel = z;
}

//
//
// AnimatedTerrainObject
//
//
inline
AnimatedTerrainObject::AnimatedTerrainObject( WorldMap* map, const SHAPEID& shpid )
	: TerrainObject(map,shpid)
{
	long shapeLength;
	PSHAPEENTRY shapeEntry = GetShape( worldMap->u7Files->shapeFile, shapeID.shapeType, &shapeLength );
	maxFrames = GetShapeFrameCount( shapeEntry, shapeLength );
	curFrame = 0;

	worldMap->tqueue->Add( worldMap->tqueue->currentTime + 10, this, (void*)worldMap->tqueue );
}

inline
void AnimatedTerrainObject::HandleEvent( unsigned long time, void* context)
{
	int frames = time / 200000;
	frames %= maxFrames;
	shapeID.shapeFrame = frames;

	TimeQueue* tq = (TimeQueue*)context;
	tq->Add( time + 200000, this, context );
}



//
//
// IregObject inline functions
//
//
inline
IregObject::IregObject( WorldMap* map, const SHAPEID& shpid, const unsigned char* ireg )
	: BasicObject(map, shpid)
{
	if ( ireg )
	{
		memcpy( info, ireg, *ireg + 1 );
	}
	else
	{
		info[0] = 0;
	}
}

inline
IregObject::~IregObject()
{
	for ( OBJITR itr = contained.begin(); itr != contained.end(); ++itr )
	{
		delete (*itr);
	}
	contained.clear();
}

inline
void IregObject::AddObject( BasicObject* obj )
{
	contained.push_back(obj);
	obj->container = this;
}

inline
bool IregObject::IsContainer() const
{
	const TFA* pTFA = GetShapeTFA(worldMap->u7Files->tfaFile,shapeID.shapeType);
	return (pTFA->shapeClass == SC_CONTAINER) || (pTFA->shapeClass == SC_HUMAN);
}


